/*
 *  renderer.h
 *  
 *  Created by James Dykstra
 *	Team 5
 *
 *  Copyright 2010 Michigan Technological University. All rights reserved.
 */

#ifndef RENDERER_H
#define RENDERER_H

//Defined constants specifying the resolution to use
#define RES_WIDTH 1024
#define RES_HEIGHT 768
#define SCREEN_BPP 32

#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_opengl.h"
#include <string>
//Just used for outputting to a log file, temporary
#include <fstream>

class Sprite;

class Renderer
{
public:
	Renderer();
	~Renderer();

	void update();

	//Used to load an image from file to an SDL_Surface, see .cpp for details
	SDL_Surface *loadImage(std::string filename);

	//Creates an OpenGL texture from an SDL_Surface*
	GLuint       createTexture(SDL_Surface *);

	//Draws the specified surface at the given coordinates/pos with the possibly specified clip, see .cpp for details.
	void         drawSurface(SDL_Rect *pos, GLfloat angle, GLuint texture);
	void         drawSurface(Sprite*);

	//For per-pixel collision detection
	Uint32       getPixelAt(SDL_Surface*, int, int);
	
	//used by the map to draw itself
	int			 getScreenWidth();
	int			 getScreenHeight();

	void		 drawBox(int,int,int,int,float);

private:
	SDL_Surface				*screen;

	bool					isPow2(int n){ return ( (n > 0) && ((n & (n - 1)) == 0) ); };
};

#endif
